import { BadRequestException } from '@nestjs/common/exceptions/bad-request.exception';

enum StatusCode {
  HTTP_SUCCESS = 200,
  HTTP_ERROR = 500,
  HTTP_NOT_FOUND = 404,
  HTTP_UNAUTHORIZED = 401,
  HTTP_FORBIDDEN = 403,
}

// 成功
export const HTTP_SUCCESS_CODE = StatusCode.HTTP_SUCCESS;
// 失败
export const HTTP_ERROR_CODE = StatusCode.HTTP_ERROR;
// 404
export const HTTP_NOT_FOUND_CODE = StatusCode.HTTP_NOT_FOUND;
// 未授权
export const HTTP_UNAUTHORIZED_CODE = StatusCode.HTTP_UNAUTHORIZED;
// 无权限
export const HTTP_FORBIDDEN_CODE = StatusCode.HTTP_FORBIDDEN;

// 错误请求
export function BadRequestExceptionFn(message: string = '请求错误') {
  throw new BadRequestException(message);
}
